# added by yinchao, Sat June 22 15:23	2024

import string

fhand = open('romeo-full.txt', 'r')

counter = {}
for line in fhand:
    line = line.translate(line.maketrans('', '', string.punctuation)).lower()
    words = line.split()
    for word in words:
        counter[word] = counter.get(word, 0) + 1


print(counter)

# translate 的另一个示例
# replace by unicode ordinals
translate = str.maketrans({
    chr(i): chr(i - 32) for i in range(ord('a'), ord('z') + 1)
})

input_str = 'yinchao'
print(input_str.translate(translate))

# replace
translate = str.maketrans('yinchao', '1234567')
input_str = 'yinchao'
print(input_str.translate(translate))

# delete
translate = str.maketrans('', '', 'yc')
input_str = 'yinchao'
print(input_str.translate(translate))
